/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package koala.objects;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class Admin {
    /** MUST HAVE DATABASE AND DATA DESIGN!!! XD **/
    
   static void startServer(){
        try{
            final Class<?> serve = Class.forName("koalaObjects.chat.Server");
            final Method method = serve.getMethod("main", String[].class);
            final Object[] args = new Object[1];
            args[0] = new String[] {"1","2"};
            method.invoke(null, args);
        }catch(final ClassNotFoundException | 
         IllegalAccessException | IllegalArgumentException | NoSuchMethodException | 
         SecurityException | InvocationTargetException exception){
        
        }
    }
    
    
    static Project createProject(ArrayList<User> userlist, int size){
        Project project = new Project();
        ArrayList<User> projectMembers = new ArrayList<>();
        String projectName = "";
        project.setProjectName(projectName);
       
        String input = "";//getting shit from the jTextField
        Object x = input;
        project.setProjectLeader((ProjectLeader)Admin.checkList(projectMembers, (User)x));
        return project;
    }
    
    static User checkList(ArrayList<User> userlist, User name){
        if(userlist.contains(name)){
            return (ProjectLeader)userlist.get(userlist.indexOf(name));
        } else {
            return null;
        }
    }
    
    
    static void setUserInactive(ArrayList<User> userlist, User user){
        if(userlist.contains(user)){
            userlist.get(userlist.indexOf(user)).setState(false);
        }
    }
    
    static void seUsertActive(ArrayList<User> userlist, User user){
        if(userlist.contains(user)){
            userlist.get(userlist.indexOf(user)).setState(true);
        }
    }
}
